self.onmessage = function (e, t) {
    e.data && (e = e.data);
    var i, r, s, a, n = e.dat, o = e.par, d = [], c = [], l = [], h = e.df, _ = e.t_id, u = e.t_cnt, g = e.m, f = g[o],
        p = e.sel, m = function (e, i, r) {
            r = r ? r.concat() : [], i && r.unshift(i);
            var s, a, n, o, d = e.id.toString(), c = {
                id: d,
                text: e.text || "",
                icon: e.icon === t || e.icon,
                parent: i,
                parents: r,
                children: e.children || [],
                children_d: e.children_d || [],
                data: e.data,
                state: {},
                li_attr: {id: !1},
                a_attr: {href: "#"},
                original: !1
            };
            for (s in h) h.hasOwnProperty(s) && (c.state[s] = h[s]);
            if (e && e.data && e.data.jstree && e.data.jstree.icon && (c.icon = e.data.jstree.icon), c.icon !== t && null !== c.icon && "" !== c.icon || (c.icon = !0), e && e.data && (c.data = e.data, e.data.jstree)) for (s in e.data.jstree) e.data.jstree.hasOwnProperty(s) && (c.state[s] = e.data.jstree[s]);
            if (e && "object" == typeof e.state) for (s in e.state) e.state.hasOwnProperty(s) && (c.state[s] = e.state[s]);
            if (e && "object" == typeof e.li_attr) for (s in e.li_attr) e.li_attr.hasOwnProperty(s) && (c.li_attr[s] = e.li_attr[s]);
            if (c.li_attr.id

                || (c.li_attr.id

                    = d), e && "object" == typeof e.a_attr) for (s in e.a_attr) e.a_attr.hasOwnProperty(s) && (c.a_attr[s] = e.a_attr[s]);
            for (e && e.children && e.children === !0 && (c.state.loaded = !1, c.children = [], c.children_d = []), g[c.id] = c, s = 0, a = c.children.length; s < a; s++) n = m(g[c.children[s]], c.id, r), o = g[n], c.children_d.push(n), o.children_d.length && (c.children_d = c.children_d.concat(o.children_d));
            return delete e.data, delete e.children, g[c.id].original = e, c.state.selected && l.push(c.id), c.id
        }, v = function (e, i, r) {
            r = r ? r.concat() : [], i && r.unshift(i);
            var s, a, n, o, d, c = !1;
            do c = "j" + _ + "_" + ++u; while (g[c]);
            d = {
                id: !1,
                text: "string" == typeof e ? e : "",
                icon: "object" != typeof e || e.icon === t || e.icon,
                parent: i,
                parents: r,
                children: [],
                children_d: [],
                data: null,
                state: {},
                li_attr: {id: !1},
                a_attr: {href: "#"},
                original: !1
            };
            for (s in h) h.hasOwnProperty(s) && (d.state[s] = h[s]);
            if (e && e.id && (d.id = e.id.toString()), e && e.text && (d.text = e.text), e && e.data && e.data.jstree && e.data.jstree.icon && (d.icon = e.data.jstree.icon), d.icon !== t && null !== d.icon && "" !== d.icon || (d.icon = !0), e && e.data && (d.data = e.data, e.data.jstree)) for (s in e.data.jstree) e.data.jstree.hasOwnProperty(s) && (d.state[s] = e.data.jstree[s]);
            if (e && "object" == typeof e.state) for (s in e.state) e.state.hasOwnProperty(s) && (d.state[s] = e.state[s]);
            if (e && "object" == typeof e.li_attr) for (s in e.li_attr) e.li_attr.hasOwnProperty(s) && (d.li_attr[s] = e.li_attr[s]);
            if (d.li_attr.id

                && !d.id && (d.id = d.li_attr.id

                    .toString()), d.id || (d.id = c), d.li_attr.id

                || (d.li_attr.id

                    = d.id), e && "object" == typeof e.a_attr) for (s in e.a_attr) e.a_attr.hasOwnProperty(s) && (d.a_attr[s] = e.a_attr[s]);
            if (e && e.children && e.children.length) {
                for (s = 0, a = e.children.length; s < a; s++) n = v(e.children[s], d.id, r), o = g[n], d.children.push(n), o.children_d.length && (d.children_d = d.children_d.concat(o.children_d));
                d.children_d = d.children_d.concat(d.children)
            }
            return e && e.children && e.children === !0 && (d.state.loaded = !1, d.children = [], d.children_d = []), delete e.data, delete e.children, d.original = e, g[d.id] = d, d.state.selected && l.push(d.id), d.id
        };
    if (n.length && n[0].id !== t && n[0].parent !== t) {
        for (r = 0, s = n.length; r < s; r++) n[r].children || (n[r].children = []), g[n[r].id.toString()] = n[r];
        for (r = 0, s = n.length; r < s; r++) g[n[r].parent.toString()].children.push(n[r].id.toString()), f.children_d.push(n[r].id.toString());
        for (r = 0, s = f.children.length; r < s; r++) i = m(g[f.children[r]], o, f.parents.concat()), c.push(i), g[i].children_d.length && (c = c.concat(g[i].children_d));
        for (r = 0, s = f.parents.length; r < s; r++) g[f.parents[r]].children_d = g[f.parents[r]].children_d.concat(c);
        a = {cnt: u, mod: g, sel: p, par: o, dpc: c, add: l}
    } else {
        for (r = 0, s = n.length; r < s; r++) i = v(n[r], o, f.parents.concat()), i && (d.push(i), c.push(i), g[i].children_d.length && (c = c.concat(g[i].children_d)));
        for (f.children = d, f.children_d = c, r = 0, s = f.parents.length; r < s; r++) g[f.parents[r]].children_d = g[f.parents[r]].children_d.concat(c);
        a = {cnt: u, mod: g, sel: p, par: o, dpc: c, add: l}
    }
    return "undefined" != typeof window && "undefined" != typeof window.document ? a : void postMessage(a)
}